-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for doc comments in icrate generation #435
base: master
Are you sure you want to change the base?
Support for doc comments in icrate generation #435
Conversation
@@ -0,0 +1,126 @@ | |||
//! Utilities for manipulating C/C++ comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this file straight out of bindgen and then modified it for some of the extra gross objective-c comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave attribution in the file? I think that should alleviate most licensing issues (they have a different license than us), but IANAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I remember trying this before I discovered the "-fretain-comments-from-system-headers" flag, and then never got back to it, but this is really nice!
My biggest complaint is that the generated doc strings have various type annotations meant for something like sphinx. It makes them just kinda gross.
Yeah, I can see a few options for resolving that:
Entity::get_parsed_comment
, if it handles those tags? If not, maybe it's possible to turn on aclang
feature flag to handle that?- Shell out to some sort of external
sphinx
parser. - Investigate how Xcode handles them normally, maybe use their implementation (if it's open-source, probably difficult otherwise)
But it's still better than nothing.
Also, some of the comments don't work great with some of the macros.
Yeah, typed_enum
, typed_extensible_enum
and extern_static
need a $(#[$m:meta])*
in their definition, should be fairly simple (see icrate/src/macros.rs
).
crates/header-translator/src/stmt.rs
Outdated
@@ -447,12 +455,14 @@ impl Stmt { | |||
designated_initializers, | |||
derives: data.map(|data| data.derives.clone()).unwrap_or_default(), | |||
ownership: data.map(|data| data.ownership.clone()).unwrap_or_default(), | |||
comment: comment.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to duplicate the comment on the class to the Methods
and ProtocolImpl
. Sure, impl MyClass
and impl MyProtocol for MyClass
won't have any comments associated with them if we don't clone it, but I think that's better.
Same goes for ProtocolImpl
in categories.
@@ -0,0 +1,126 @@ | |||
//! Utilities for manipulating C/C++ comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave attribution in the file? I think that should alleviate most licensing issues (they have a different license than us), but IANAL.
…ts-to-header-translator
I'm not sure there's an issue for this but saw the
TODO
and felt like doing it. My biggest complaint is that the generated doc strings have various type annotations meant for something like sphinx. It makes them just kinda gross.Also, some of the comments don't work great with some of the macros.